package main

import (
	"fmt"
	"reflect"
)

func reflectTest02(b interface{}) {
	rType := reflect.TypeOf(b)
	fmt.Println("rType =", rType)
	rVal := reflect.ValueOf(b)
	iV := rVal.Interface()
	fmt.Printf("iV = %v iv = %T\n", iV, iV)

	stu, _ := iV.(Student)
	fmt.Println(stu.Name)
}

type Student struct {
	Name string
	Age int
}

func main() {

	// 演示对(结构体类型、interface{}、reflect.Value)进行反射的基本操作

	// 定义Student的实例
	stu := Student{
		Name: "tom",
		Age: 20,
	}
	reflectTest02(stu)

}